/**
 * Copyright (C) 2018-2021
 * All rights reserved, Designed By www.yixiang.co

 */
package co.yixiang.modules.cart.domain;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import co.yixiang.domain.BaseDomain;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

/**
* @author hupeng
* @date 2020-05-12
*/

@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@TableName("yx_store_cart")
public class YxStoreCart extends BaseDomain {

    /** 购物车表ID */
    @TableId
    private Long id;


    /** 用户ID */
    private Long uid;


    /** 类型 */
    private String type;


    /** 商品ID */
    private Long productId;


    /** 商品属性 */
    private String productAttrUnique;


    /** 商品数量 */
    private Integer cartNum;




    /** 0 = 未购买 1 = 已购买 */
    private Integer isPay;



    /** 是否为立即购买 */
    private Integer isNew;


    /** 拼团id */
    //@Column(name = "combination_id")
    private Long combinationId;


    /** 秒杀产品ID */
    private Long seckillId;


    /** 砍价id */
    private Long bargainId;

    public static YxStoreCartBuilder builder() {
        return new YxStoreCartBuilder();
    }


    public void copy(YxStoreCart source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }

    public static class YxStoreCartBuilder {
        private Long id;
        private Long uid;
        private String type;
        private Long productId;
        private String productAttrUnique;
        private Integer cartNum;
        private Integer isPay;
        private Integer isNew;
        private Long combinationId;
        private Long seckillId;
        private Long bargainId;

        YxStoreCartBuilder() {
        }

        public YxStoreCartBuilder id(Long id) {
            this.id = id;
            return this;
        }

        public YxStoreCartBuilder uid(Long uid) {
            this.uid = uid;
            return this;
        }

        public YxStoreCartBuilder type(String type) {
            this.type = type;
            return this;
        }

        public YxStoreCartBuilder productId(Long productId) {
            this.productId = productId;
            return this;
        }

        public YxStoreCartBuilder productAttrUnique(String productAttrUnique) {
            this.productAttrUnique = productAttrUnique;
            return this;
        }

        public YxStoreCartBuilder cartNum(Integer cartNum) {
            this.cartNum = cartNum;
            return this;
        }

        public YxStoreCartBuilder isPay(Integer isPay) {
            this.isPay = isPay;
            return this;
        }

        public YxStoreCartBuilder isNew(Integer isNew) {
            this.isNew = isNew;
            return this;
        }

        public YxStoreCartBuilder combinationId(Long combinationId) {
            this.combinationId = combinationId;
            return this;
        }

        public YxStoreCartBuilder seckillId(Long seckillId) {
            this.seckillId = seckillId;
            return this;
        }

        public YxStoreCartBuilder bargainId(Long bargainId) {
            this.bargainId = bargainId;
            return this;
        }

        public YxStoreCart build() {
            return new YxStoreCart(id, uid, type, productId, productAttrUnique, cartNum, isPay, isNew, combinationId, seckillId, bargainId);
        }

        public String toString() {
            return "YxStoreCart.YxStoreCartBuilder(id=" + this.id + ", uid=" + this.uid + ", type=" + this.type + ", productId=" + this.productId + ", productAttrUnique=" + this.productAttrUnique + ", cartNum=" + this.cartNum + ", isPay=" + this.isPay + ", isNew=" + this.isNew + ", combinationId=" + this.combinationId + ", seckillId=" + this.seckillId + ", bargainId=" + this.bargainId + ")";
        }
    }
}
